import 'package:flutter/material.dart';
import 'package:flutter2/colors.dart';
import 'package:flutter2/utils/string.dart';
import 'package:flutter2/widget/base/normal_text.dart';

class StepView extends StatelessWidget {
  const StepView({
    super.key,
    required this.max,
    required this.step,
  });

  final int max;
  final int step;

  @override
  Widget build(BuildContext context) {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Expanded(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: buildStep(),
          ),
        ),
        NormalText(
          text: "$step",
          fontColor: btnColor,
          fontSize: 12,
        ),
        NormalText(
          text: "/$max",
          fontColor: mainText2,
          fontSize: 12,
        )
      ],
    );
  }

  List<Widget> buildStep() {
    List<Widget> list = [];
    for (int i = 0; i < max; i++) {
      list.add(
        Expanded(
          child: Container(
            height: 6,
            decoration: BoxDecoration(
              color: i < step ? btnColor : "E6ECE9".toColor(),
              borderRadius: BorderRadius.circular(10),
            ),
          ),
        ),
      );
      list.add(SizedBox(width: 8));
    }
    return list;
  }
}
